package lesson15Class;

class Person 
{
	String name;
	int age;
	String personalNumber;
	char sex;
	double weight;
	Person[] friends;
	int health = 50;//from 0 to 100
	int starvationStatus = 50;//from 0 to 100
	int mentalStatus = 50;//from 0 to 100
	int carsCapacity;//the number of cars the person can buy
	double money;
	Car car;
	
	Person()
	{
		age =0;
		weight = 4.0;
	}
	
	Person(String name, String personalNumber, boolean isMale)
	{
		this();
		if(isMale)
			sex = 'M';
		else
			sex = 'F';
		this.name = name;
		this.personalNumber = personalNumber;
		friends = new Person[3];
	}
	
	Person(String personName)
	{
		name = personName;
	}
		
	Person(String personName, int personAge)
	{
		age = personAge;
		name = personName;
	}
	
	double sellCarForScrap()
	{
		double metalPrice = 0.37;//stotinki na kilo stomana
		double returnedMoney = car.calculatePriceForScrap(metalPrice);
		this.money += returnedMoney;
		return returnedMoney;
	}
	
	
	void buyCar(Car car)
	{
		if(this.money >= car.price)
		{
			this.car = car;
			car.changeOwner(this);
		}
		//buy car if enought money in the bank account
	}
	
	void eat(int foodVolume)
	{
		if(starvationStatus+foodVolume >= 100)
			starvationStatus = 100;
		else
			starvationStatus +=foodVolume;
	}
	
	void walk()
	{
		System.out.println(name + " is walking");
		starvationStatus-=5;
	}
	
	void growUp()
	{
		age++;
	}
	
	void drinkWater(double litres)
	{
		System.out.println(name +" is drinking " + litres + " litres of water");
		starvationStatus+=litres;
	}

	public void initializeCarsCapacity() 
	{
		carsCapacity = (int)Math.round(Math.random() + 1);
	}

	public boolean willingToBuy() 
	{
		return (Math.round(Math.random() + 1)) == 1;
	}
	
	
}
